/* DOrdinationsZeit.java
 *
 * Author:	Malcolm Staudacher
 * Date:	May 1, 2008
 *
 */

package ocumed.domaene.benutzerverwaltung.arztverwaltung;

import java.util.Calendar;

import ocumed.domaene.benutzerverwaltung.DBenutzer;
import ocumed.teams.IBenutzer;
import ocumed.teams.IOrdination;

/**
 * provide domain functionality for a doctor's working time
 * 
 * @author Malcolm Staudacher
 * @author Daniel Rudigier
 *
 */
public class DOrdinationsZeit implements Comparable<DOrdinationsZeit>, IOrdination {

	private int m_id;
	private DBenutzer m_arzt;
	private int m_tag;
	private String m_tagName;
	private Calendar m_anfang;
	private Calendar m_ende;


	public DOrdinationsZeit(int id, DBenutzer arzt, String tag,
			Calendar anfang, Calendar ende) {
		super();
		m_id = id;
		m_arzt = arzt;
		m_tagName = tag;

		if (tag.equals("mo")) {
			m_tag = Calendar.MONDAY;
		} else if (tag.equals("di")) {
			m_tag = Calendar.TUESDAY;
		} else if (tag.equals("mi")) {
			m_tag = Calendar.WEDNESDAY;
		} else if (tag.equals("do")) {
			m_tag = Calendar.THURSDAY;
		} else if (tag.equals("fr")) {
			m_tag = Calendar.FRIDAY;
		} else if (tag.equals("sa")) {
			m_tag = Calendar.SATURDAY;
		} else if (tag.equals("so")) {
			m_tag = Calendar.SUNDAY;
		}

		m_anfang = anfang;
		m_ende = ende;

		// disregard seconds and milliseconds
		m_anfang.set(Calendar.SECOND, 0);
		m_anfang.set(Calendar.MILLISECOND, 0);
		m_ende.set(Calendar.SECOND, 0);
		m_ende.set(Calendar.MILLISECOND, 0);
	}


	/**
     * override
     *
     * @see ocumed.teams.IOrdination#getArzt()
     */
	public IBenutzer getiBenutzer() {
		return m_arzt;
	}


	public int compareTo(DOrdinationsZeit o) {

		if (m_anfang.before(o.m_anfang)) {
			return -1;
		} else if (m_anfang.after(o.m_anfang)) {
			return 1;
		}

		return 0;
	}


	/**
     * override
     *
     * @see ocumed.teams.IOrdination#getTag()
     */
	public int getTag() {
		return m_tag;
	}


	/**
     * override
     *
     * @see ocumed.teams.IOrdination#getAnfang()
     */
	public Calendar getAnfang() {
		return m_anfang;
	}


	/**
     * override
     *
     * @see ocumed.teams.IOrdination#getEnde()
     */
	public Calendar getEnde() {
		return m_ende;
	}


	/**
     * override
     *
     * @see ocumed.teams.IOrdination#getId()
     */
	public int getId() {
		return m_id;
	}


	/**
     * override
     *
     * @see ocumed.teams.IOrdination#setId(int)
     */
	public void setId(int id) {
		m_id = id;
	}


	/**
     * override
     *
     * @see ocumed.teams.IOrdination#setArzt(ocumed.domaene.benutzerverwaltung.DBenutzer)
     */
	public void setArzt(DBenutzer arzt) {
		m_arzt = arzt;
	}


	/**
     * override
     *
     * @see ocumed.teams.IOrdination#setTag(int)
     */
	public void setTag(int tag) {
		m_tag = tag;
	}


	/**
     * override
     *
     * @see ocumed.teams.IOrdination#setAnfang(java.util.Calendar)
     */
	public void setAnfang(Calendar anfang) {
		m_anfang = anfang;
	}


	/**
     * override
     *
     * @see ocumed.teams.IOrdination#setEnde(java.util.Calendar)
     */
	public void setEnde(Calendar ende) {
		m_ende = ende;
	}


	/**
     * override
     *
     * @see ocumed.teams.IOrdination#getTagName()
     */
	public String getTagName() {
		return m_tagName;
	}


	/**
     * override
     *
     * @see ocumed.teams.IOrdination#setTagName(java.lang.String)
     */
	public void setTagName(String tagName) {
		m_tagName = tagName;
	}

}
